package org.jtb.quickr;

import java.io.InputStream;
import java.util.Map;
import org.apache.log4j.Logger;

class PeopleGetInfoRequest extends MethodRequest {
    private static Logger logger = Logger.getLogger(PeopleGetInfoRequest.class.getName());
    
    private String nsId;
    private String staticUrl;
    
    protected PeopleGetInfoRequest(String baseUrl, String apiKey, String nsid, String staticUrl) throws QuickrException {
        super(baseUrl, apiKey, "flickr.people.getInfo");
        this.nsId = nsid;
        this.staticUrl = staticUrl;
    }
        
    protected Map<String,String> getArgs() {
        putArg("user_id", getNsid());      
        
        return super.getArgs();
    }

    public PersonResponse execute() throws QuickrException {
        FlickrUrl furl = new ServiceMethodUrl(getBaseUrl(), getArgs(), getApiKey(), getMethod());
        Get get = new Get(furl.getUrl());
        InputStream is = get.execute();

        PersonResponse pres = new PersonResponse(is, staticUrl);
        
        return pres;
    }

    protected String getNsid() {
        return nsId;
    }
}
